package async;

import java.util.concurrent.ExecutionException;

/**
 * @Author: linKe
 * @Date: 2022/1/14 17:28
 * @FileName: AsyncResult
 * @version: 1.0
 * @Description: 一次异步执行的结果
 */
public interface AsyncResult<T> {
    /**
     * 是否完成
     * @return 结果
     */
    boolean isComplete();

    /**
     * 获取值
     * @return 结果
     * @throws ExecutionException 执行异常
     */
    T getValue() throws ExecutionException;

    /**
     * 阻塞当前线程，知道执行结束
     * @throws InterruptedException   执行中断异常
     */
    void await() throws InterruptedException;
}
